#include <iostream>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const LL mod = 998244353;

LL qpow(LL a, LL b)
{
    LL ret = 1;
    while(b)
    {
        if(b & 1) ret = ret * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return ret;
}

void solve()
{
    LL n, m; cin >> n >> m;
    if(n % 2 == 0 && m % 2 == 0) cout << 2 << endl;
    else if(n % 2 == 0) cout << qpow(2, n - 1) << endl;
    else if(m % 2 == 0) cout << qpow(2, m - 1) << endl;
    else cout << qpow(2, m + n - 2) << endl;
}

int main()
{
    int T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}